<!-- if $session.user_id -->
<div class="card">
	<div class="card-header">
		收件人信息
		<div class="float-right"><input type="button" value="添加新地址" onclick="$.cart.address()" class="btn btn-secondary btn-sm" /></div>
	</div>
	<!-- if $address_list -->
	<ul class="list-group list-group-flush">
		<!-- loop from=$address_list key=$key value=$value id=$tmpid -->
		<li class="list-group-item">
			<div class="row">
				<div class="col-7">
					<input type="radio" name="address_id" id="address_id_{$value.id}" value="{$value.id}"{if $address_id == $value.id} checked{/if} onclick="load_freight()" />
					<label for="address_id_{$value.id}">{$value.fullname}</label>
					<!-- if $value.mobile -->
					<small>（{func substr $value.mobile 0 3}****{func substr $value.mobile -3}）</small>
					<!-- /if -->
				</div>
				
				<div class="col-5 text-right">
					<input type="button" value="编辑" onclick="$.cart.address('{$value.id}')" class="btn btn-secondary btn-sm" />
					<!-- if !$value.is_default -->
					<input type="button" value="设为默认" class="btn btn-secondary btn-sm" onclick="$.address.set_default('{$value.id}')" />
					<!-- /if -->
				</div>
				<div class="col-12 col-sm-6"><b>地址：</b><!-- if $value.country != '中国' -->（{$value.country}）<!-- /if -->{$value.province}<!-- if $value.province != $value.city -->{$value.city}<!-- /if -->{$value.county}{$value.address}</div>
				
			</div>
		</li>
		<!-- /loop -->
	</ul>
	<!-- /if -->
	<!-- if $address_id -->
	<script type="text/javascript">
	$(document).ready(function(){
		load_freight();
	});
	</script>
	<!-- /if -->
</div>
<!-- else -->
<div class="card">
	<div class="card-header">
		收件人信息
	</div>
	<div class="card-body">
		<div class="form-group">
			<label for="fullname">收件人</label>
			<div class="am-u-sm-10">
				<input type="text" id="fullname" class="form-control" name="fullname" placeholder="填写收件人姓名"/>
			</div>
		</div>
		<div class="form-group">
			<label for="fullname">地址</label>
			<div class="pca row">
				<div class="col">
					<select name="country" id="country" onchange="$.address.glist()">
						<option value="">请选择…</option>
					</select>
				</div>
				<div class="col">
					<select name="province" id="province" onchange="$.address.glist()">
						<option value="">请选择…</option>
					</select>
				</div>
				<div class="col">
					<select name="city" id="city" onchange="$.address.glist()">
						<option value="">请选择…</option>
					</select>
				</div>
				<div class="col">
					<select name="county" id="county">
						<option value="">请选择…</option>
					</select>
				</div>
			</div>
			<input type="text" class="form-control mt-2" name="address" id="address" value="{$rs.address}" style="margin-top:3px;" />
		</div>
		<div class="form-group">
			<label for="mobile">手机号码</label>
			<input type="tel" id="mobile" class="form-control" name="mobile" value="{$rs.mobile}" placeholder="填写有效的手机号码" />
		</div>
		<div class="form-group">
			<label for="tel">固定电话</label>
			<input type="tel" id="tel" name="tel" class="form-control" value="{$rs.tel}" placeholder="填写有效的固定电话，带上区号，示例：0755-12345678" />
		</div>
		<div class="form-group">
			<label for="email">邮箱 Email</label>
			<input type="email" id="email" name="email" class="form-control" value="{$rs.email}" placeholder="用来接收订单提醒邮件，便于您及时了解订单状态" />
		</div>
	</div>
	<script type="text/javascript">
	var old_province = '';
	var old_country = '';
	var old_city = '';
	function monitor_address()
	{
		var country = $("#country").val();
		var province = $("#province").val();
		var city = $("#city").val();
		if(country && province && city && (country != old_country || province != old_province || city != old_city)){
			load_freight();
			old_country = country;
			old_province = province;
			old_city = city;
		}
		window.setTimeout('monitor_address()',1000);
	}
	$(document).ready(function(){
		monitor_address();
		$.address.glist();
		$("select").addClass("form-control");
	});
	</script>
</div>
<!-- /if -->